{extend name="base" /}
{block name="content"}
<script language="javascript" type="text/javascript" src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>积分商城</span>
            <span class="icon-angle-right"></span>
            <span>积分商城商品管理</span>
            <span class="icon-angle-right"></span>
            <span>积分商城商品管理</span>
            <span class="icon-angle-right"></span>
            <span>{$info ? '编辑' : '添加'}积分商城商品</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-tab-tit clearfix">
                <ul>
                    <li><a href="javascript:;">基本设置</a></li>
                    {if condition="session('role_id', '', session_prefix()) eq 1"}
                    <li><a href="javascript:;">SEO设置</a></li>
                    {/if}
                </ul>
            </div>
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <div class="m-tab-con">
                        <table class="m-table">
                            <tbody>
                                <tr>
                                <th colspan="2">积分商城商品信息</th>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_name">商品名称<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-longer" name="goods_name" id="goods_name" placeholder="请输入商品名称" value="{$info.goods_name}" /></td>
                                </tr>
								<tr>

                                    <td><label for="">商品品牌<em>*</em></label></td>

                                    <td>

                                        <div class="lay-select m-select-def">

                                            <select name="brand_id">

                                                <option value="0">请选择商品品牌</option>

                                                {foreach name="brands" item="v"}

                                                <option value="{$v.id}"{if condition="$info['brand_id'] eq $v['id']"} selected{/if}>{$v.name}</option>

                                                {/foreach}

                                            </select>

                                        </div>

                                    </td>
                            </tr>
                             <!-- <tr>
                                <td><label for="">所属分类<em>*</em></label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="category_id" lay-filter="category_id">
                                            <option value="0">请选择分类</option>
                                            {foreach name="categories" item="v"}
                                            <option value="{$v.id}"{if condition="!$v['is_last']"} disabled{/if}{if condition="$info['category_id'] eq $v['id']"} selected{/if}>{$v.html|html_entity_decode}|-{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </td>
                             </tr> -->
                          
                            <tr>
                                <td width="15%"><label for="goods_unit">商品单位</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_unit" id="goods_unit" placeholder="请输入商品单位" value="{$info.goods_unit|default=''}" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="point">所需积分</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="point" id="point" placeholder="请输入所需积分" value="{$info.point|default='0'}" /></td>
                            </tr>
                           
                            <tr>
                                <td width="15%"><label for="diy_sale_nums">自定义销量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="diy_sale_nums" id="diy_sale_nums" placeholder="请输入自定义销量" value="{$info.diy_sale_nums|default='0'}" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="actual_sale_nums">实际销量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="actual_sale_nums" id="actual_sale_nums" placeholder="请输入实际销量" value="{$info.actual_sale_nums|default='0'}" readonly /></td>
                            </tr>
                           
                            <tr>
                                <td width="15%"><label for="goods_stock">总库存<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_stock" id="goods_stock" placeholder="请输入总库存" value="{$info.goods_stock|default='0'}"{if condition="$info && $info['goods_spec_format']"} readonly{/if} /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_stock_alarm">库存预警</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_stock_alarm" id="goods_stock_alarm" placeholder="请输入库存预警数量" value="{$info.goods_stock_alarm|default='0'}" /><span>设置最低库存预警值。当库存低于预警值时商家中心商品列表页库存列红字提醒。0 为不预警。</span></td>
                            </tr>
                            <tr>
                                <th colspan="2">商品模型</th>
                            </tr>
                            <tr>
                                <td rowspan="2"><label for="">商品模型</label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="good_mods_id" lay-filter="good_mods_id">
                                            <option value="0">请选择商品模型</option>
                                            {foreach name="goodMods" item="v"}
                                            <option value="{$v.id}"{if condition="$info['good_mods_id'] eq $v['id']"} selected{/if}>{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="m-good-specs">
                                    <table class="m-table">
                                        <thead>
                                            <tr>
                                                <th colspan="2">
                                                    <h3>操作提示</h3>
                                                    <p>1、双击规格值进行编辑操作（失去光标自动保存）。</p>
                                                    <p>2、鼠标浮上图片时，可以进行预览。</p>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody id="j_spec"></tbody>
                                    </table>
                                </td>
                            </tr>
                            <tr id="j_sku" class="dn">
                                <td><label for="">商品sku</label></td>
                                <td class="m-good-sku" id="j_good_sku"></td>
                            </tr>
                            <tr>
                                <th colspan="2">商品图片</th>
                            </tr>
                            <tr>
                                <td><label for="">商品缩略图</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pic" data-name="goods_thumb_id"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pic">
                                        <ul>
                                            {:attach_html($info.goods_thumb_id, 'goods_thumb_id')}
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="">商品相册</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pics" data-name="goods_album"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pics">
                                        <ul>
                                            {:attach_html($info.goods_album, 'goods_album', 'pics')}
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                    <th colspan="2">商品详情</th>
                                </tr>
 								<tr>

                                    <td><label for="goods_keywords">商品关键词<em>*</em></label></td>

                                    <td><input type="text" class="u-ipt u-ipt-long" name="goods_keywords" id="goods_keywords" placeholder="请输入商品关键词" value="{$info.goods_keywords}" /></td>

                                </tr>

                                <tr>

                                    <td><label for="goods_intro">商品简介<em>*</em></label></td>

                                    <td><div class="m-textarea"><textarea name="goods_intro" class="u-tarea" id="goods_intro" placeholder="请输入商品简介">{$info.goods_intro}</textarea></div></td>

                                </tr>
                                <tr>
                                    <td colspan="2"><label for="">商品详情<em>*</em></label></td>
                                </tr>
                                <tr>
                                    <td colspan="2"><textarea name="goods_detail" style="width:100%;height:300px;visibility:hidden;">{$info.goods_detail}</textarea></td>
                                </tr>
                                <input type="hidden" value="{$info.status}" name="status" id="status" /><!--审核状态-->
                            </tbody>
                        </table>
                    </div>
                    <div class="m-tab-con dn">
                        <table class="m-table">
                            <tbody>
                            <tr>
                                <td><label for="">是否上架</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_sale" value="1" title="是" lay-skin="primary"{$info.is_sale ? ' checked' : ''} /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否新品</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_latest" value="1" title="是" lay-skin="primary"{$info.is_latest ? ' checked' : ''} /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否推荐</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_recommand" value="1" title="是" lay-skin="primary"{$info.is_recommand ? ' checked' : ''} /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否促销</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_hot_sale" value="1" title="是" lay-skin="primary"{$info.is_hot_sale ? ' checked' : ''} /></div></td>
                            </tr>
                           <tr>

                                <td><label for="list_order">排序</label></td>

                                <td><input type="text" class="u-ipt u-ipt-tiny" name="list_order" id="list_order" placeholder="请输入排序值" value="{$info.list_order|default=0}" /><span>值越大越排在前面</span></td>

                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="m-form-btn"><input type="hidden" name="id" value="{$info.id}"><button id="j_add_goods" class="u-btn">确定提交</button></div>
                    <textarea name="goods_spec_format" class="dn"></textarea>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script src="__STATIC__/public/js/jquery-ui.min.js"></script>
{include file="public:upload"/}
{include file="public:editor"/}
<script>
var good_mods_id      = '{$info.good_mods_id}';
var goods_spec_format = eval('{$info.goods_spec_format ? html_entity_decode($info.goods_spec_format) : "[]"}');
var goods_sku         = eval('{$sku ? html_entity_decode($sku) : "[]"}');
var goods_attr        = eval('{$attr ? html_entity_decode($attr) : "[]"}');
var upload_uri        = '{:url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"])}';
var upload_btn        = '__STATIC__/manage/images/goods_sku_add.png';
var uri               = $('input[name="action_uri"]').val();
KindEditor.ready(function(K) {
    var editor = K.create('textarea[name="goods_detail"]', {
		allowFileManager: true,
        uploadJson: uploadJson,
        fileManagerJson: fileManagerJson,
        afterBlur: function () {
            this.sync();
        }
	});
});
</script>
<script src="__STATIC__/public/js/point_add.js"></script>
{/block}